package com.hxalex.simulationhandle.accessbilityService.receiver.wifi;

import android.util.Log;
import android.view.accessibility.AccessibilityNodeInfo;

import com.hxalex.simulationhandle.accessbilityService.manger.WifiManger;
import com.hxalex.simulationhandle.accessbilityService.receiver.base.BaseReceiver;

import java.util.List;

/**
 * Created by hx_Alex on 2018/5/26.
 */

public class CheckWifiInMainReceiver extends BaseReceiver  {

    private String  text;

    public CheckWifiInMainReceiver(WifiManger wifiManger) {
        super(wifiManger);
        FLAG="检查WIFI万能钥匙是否进入主页命令";
    }


    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }
    @Override
    public void doSomething() {
        if(!isPrintCommandMsg)
        {
            Log.w("CheckWifiInMainReceiver","开始执行"+FLAG);
            isPrintCommandMsg=true;
        }
        
        if(text!=null && !text.equals(""))
        if(!wifiManger.checkIsOpenWifiApp(text)) return;

        //防止跳转至其他页面先进行连接页面点击模拟
        List<AccessibilityNodeInfo> tabList = wifiManger.getTabList();
        if(tabList!=null && tabList.size()==4)
        {
            Log.w("CheckWifiInMainReceiver","点击返回主页");
            tabList.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK);
            commandCompleteListener.commandCompleteListener();
        } else
        {
            return;
        }
        
    }
}
